<?php

declare(strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 * 魅力豪气值日志
 */
class UserCharmRichLog extends Model
{
    protected $table = 'user_charm_rich_log';

    /**
     * 添加记录
     */
    static function addCharmRecord($userId = 0, $value = 0)
    {
        $model = new self();
        $model->user_id = $userId;
        $model->type = 'charm';
        $model->value = $value;
        $model->flag = 1;
        return $model->saveOrFail() ? 1 : 0;
    }

    /**
     * 添加记录
     */
    static function addRichRecord($userId = 0, $value = 0)
    {
        $model = new self();
        $model->user_id = $userId;
        $model->type = 'rich';
        $model->value = $value;
        $model->flag = 1;
        return $model->saveOrFail() ? 1 : 0;
    }
}
